<?php
namespace app\shop\model;
use app\BaseModel;
use think\facade\Cache;
//*------------------------------------------------------ */
//-- 商品品牌
/*------------------------------------------------------ */
class StoreModel extends BaseModel
{
	protected $table = 'shop_store';
	public  $pk = 'id';

    public function getList($where = [],$lng,$lat,$limit = 10)
    {
        $EARTH=6378.137; //地球半径
        $PI=3.1415926535898; //PI值　　 //将要和数据库经纬度对比的坐标
        $list = $this->field("*,round((2 * $EARTH* ASIN(SQRT(POW(SIN($PI*(".$lat."-latitude)/360),2)+COS($PI*".$lat."/180)* COS(latitude * $PI/180)*POW(SIN($PI*(".$lng."-longitude)/360),2)))),2) as juli")
        ->where($where)->order('juli asc')->paginate($limit)->toArray();
        foreach ($list['data'] as &$value){
//            $value['range'] = round($value['juli']/1000,1);
            $value['range'] = $value['juli'];
        }
        return $list;
    }
}
